using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Threading;

namespace GoogleNet
{
    /// <summary>
    /// Scales a model along the x, y, and z axes in the model's coordinate space.
    /// </summary>
    public class KmlScale : IKmlElement
    {
        private string tagName = "Scale";

        #region X
        private double x = 1;

        /// <summary>
        /// Gets or sets the X.
        /// </summary>
        /// <value>The X.</value>
        public double X
        {
            get { return x; }
            set { x = value; }
        } 
        #endregion

        #region Y
        private double y = 1;

        /// <summary>
        /// Gets or sets the Y.
        /// </summary>
        /// <value>The Y.</value>
        public double Y
        {
            get { return y; }
            set { y = value; }
        } 
        #endregion

        #region Z
        private double z = 1;

        /// <summary>
        /// Gets or sets the Z.
        /// </summary>
        /// <value>The Z.</value>
        public double Z
        {
            get { return z; }
            set { z = value; }
        } 
        #endregion


        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return tagName; }
        }

        #endregion

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);

            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
            writer.WriteElementString("x", x.ToString(Thread.CurrentThread.CurrentCulture.NumberFormat));
            writer.WriteElementString("y", y.ToString(Thread.CurrentThread.CurrentCulture.NumberFormat));
            writer.WriteElementString("z", z.ToString(Thread.CurrentThread.CurrentCulture.NumberFormat));
            Thread.CurrentThread.CurrentCulture = currentCulture;

            writer.WriteEndElement();
        }

        #endregion
    }
}
